package com.beiding.workordersystem.common.helper;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;

@WebServlet
@Component
public class SessionListener implements HttpSessionListener {

    @Autowired
    private MySessionContext mySessionContext;

    @Override
    public void sessionCreated(HttpSessionEvent se) {
        mySessionContext.addSession(se.getSession());
    }

    @Override
    public void sessionDestroyed(HttpSessionEvent se) {
        mySessionContext.delSession(se.getSession());
    }
}
